package uy.edu.um.ltic.server.business;

import java.sql.Timestamp;
import java.util.ArrayList;

import uy.edu.um.ltic.commons.ConferenceVO;
import uy.edu.um.ltic.commons.EmployeeVO;
import uy.edu.um.ltic.commons.MessageVO;

public class Conference {

	private Timestamp date;
	private String name;
	private ArrayList<Employee> participants;
	private Employee organizer;
	private ArrayList<ConferenceMessage> messages;
	
	public Conference(Timestamp dDate, ArrayList<Employee> oParticipants, Employee oOrganizer, String n){
		date = dDate;
		participants = oParticipants;
		organizer = oOrganizer;
		name = n;
		messages = new ArrayList<ConferenceMessage>(); //Cuando se crea la conferencia no hay mensajes.
	}
	
	public Conference(Timestamp dDate,Employee oOrganizer, String n){
		date = dDate;
		organizer = oOrganizer;
		name = n;
	}
	
	public Conference(ConferenceVO oCVO){
		date = oCVO.getDate();
		name = oCVO.getName();
		ArrayList<Employee> oLEm = new ArrayList<Employee>();
		for (EmployeeVO oE : oCVO.getParticipants()){
			oLEm.add(new Employee(oE));
		}
		participants = oLEm;
		organizer = new Employee(oCVO.getOrganizer());
	}
	
	public ConferenceVO convertToConferenceVO(){
		ArrayList<EmployeeVO> partiVO = new ArrayList<EmployeeVO>();
		for (Employee oE : participants){
			partiVO.add(oE.convertToEmployeeVO());
		}
		ArrayList<MessageVO> messaVO = new ArrayList<MessageVO>();
		for (ConferenceMessage oM : messages){
			messaVO.add(oM.convertToMessageVO());
		}
		
		return new ConferenceVO(date,name,partiVO,organizer.convertToEmployeeVO(),messaVO);
	}
	
	public Timestamp getDate() {
		return date;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setDate(Timestamp date) {
		this.date = date;
	}

	public ArrayList<Employee> getParticipants() {
		return participants;
	}

	public void setParticipants(ArrayList<Employee> participants) {
		this.participants = participants;
	}

	public Employee getOrganizer() {
		return organizer;
	}

	public void setOrganizer(Employee organizer) {
		this.organizer = organizer;
	}

	public ArrayList<ConferenceMessage> getMessages() {
		return messages;
	}

	public void setMessages(ArrayList<ConferenceMessage> messages) {
		this.messages = messages;
	}
	
}
